Skip to content

feat: support ansi for elt - #23928

Merged
comphead merged 3 commits into
apache:mainfrom
comphead:elt_ansi
Jul 29, 2026
Merged

feat: support ansi for elt#23928
comphead merged 3 commits into
apache:mainfrom
comphead:elt_ansi

Conversation

@comphead

@comphead comphead commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Part of #23929

Rationale for this change

Spark's elt errors on out-of-range indices when ANSI is on, and returns NULL when off. DataFusion previously always returned NULL (there was a TODO for this in the source).

What changes are included in this PR?

  • elt.rs: read enable_ansi_mode from ScalarFunctionArgs::config_options; raise "The index N is out of bounds. The array has M elements." in ANSI mode, keep NULL behavior otherwise. NULL index
    always returns NULL.
  • elt.slt: add missing ANSI-off cases (index 0, negative, large, NULL index, NULL value, vectorized) and a full ANSI-on section with statement error assertions.

Are these changes tested?

Yes. New Rust unit tests and sqllogictest cases cover both modes.

Are there any user-facing changes?

With enable_ansi_mode = true, elt on invalid indices now errors instead of returning NULL. Default behavior unchanged. No API changes.

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.70%. Comparing base (2028927) to head (2ee063b).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/spark/src/function/string/elt.rs 84.21% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23928      +/-   ##
==========================================
+ Coverage   80.67%   80.70%   +0.02%     
==========================================
  Files        1095     1095              
  Lines      372490   372554      +64     
  Branches   372490   372554      +64     
==========================================
+ Hits       300517   300658     +141     
+ Misses      54035    53926     -109     
- Partials    17938    17970      +32     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

#[test]
fn elt_ansi_valid_indices_ok() -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need these tests if theyre already covered by slts?

@comphead
comphead added this pull request to the merge queue Jul 29, 2026
@comphead

Copy link
Copy Markdown
Contributor Author

Thanks @Jefffrey for the review

Merged via the queue into apache:main with commit ef94a85 Jul 29, 2026
37 checks passed
@comphead
comphead deleted the elt_ansi branch July 29, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants